package com.shiyun.marker.cli.command;

import cn.hutool.core.bean.BeanUtil;
import com.shiyun.marker.generator.file.FileGenerator;
import com.shiyun.marker.model.DataModel;
import lombok.Data;
import picocli.CommandLine.Option;
import picocli.CommandLine;

import java.util.concurrent.Callable;

@CommandLine.Command(name="generator",mixinStandardHelpOptions = true)
@Data
public class GeneratorCommand implements Callable<Integer> {
    //定义命令行选项
    @Option(names={"-a","--author"},arity = "0..1",description = "作者" ,interactive = true,echo = true)
    String author = "shiyun";
    @Option(names={"-o","--output"},arity = "0..1", description = "输出文本",interactive = true,echo = true)
    String outputText = "sum = ";
    @Option(names={"-l","--loop"},arity = "0..1",description = "是否循环",interactive = true,echo = true)
    boolean loop;

    @Override
    public Integer call() throws Exception {
        DataModel dataModel = new DataModel();
        BeanUtil.copyProperties(this, dataModel);
        System.out.println("配置信息"+ dataModel);
        //调用生成方法
        FileGenerator.doGenerator(dataModel);
        return 0;
    }
}
